
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>TextView · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="drawable.html" />
    
    
    <link rel="prev" href="layout.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">----安卓 UI----</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="view.html">
            
                <a href="view.html">
            
                    
                    自定义控件和measure
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="canvas-paint.html">
            
                <a href="canvas-paint.html">
            
                    
                    draw和canvas，paint详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="anim.html">
            
                <a href="anim.html">
            
                    
                    动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="notify.html">
            
                <a href="notify.html">
            
                    
                    notify系列库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="loading.html">
            
                <a href="loading.html">
            
                    
                    loading系列库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="status-ui.html">
            
                <a href="status-ui.html">
            
                    
                    StatusUI系列库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="touch-scroll.html">
            
                <a href="touch-scroll.html">
            
                    
                    滑动
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="layout.html">
            
                <a href="layout.html">
            
                    
                    Layout
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.10" data-path="textview.html">
            
                <a href="textview.html">
            
                    
                    TextView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="drawable.html">
            
                <a href="drawable.html">
            
                    
                    Drawable
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="item-template.html">
            
                <a href="item-template.html">
            
                    
                    列表Adapter模板化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="recyclerview.html">
            
                <a href="recyclerview.html">
            
                    
                    RecyclerView全解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="design.html">
            
                <a href="design.html">
            
                    
                    MeterialDesign详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="component.html">
            
                <a href="component.html">
            
                    
                    AyoComponent基础库--Activity和Fragment
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="systembartint.html">
            
                <a href="systembartint.html">
            
                    
                    SystembarTint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="permission-ask.html">
            
                <a href="permission-ask.html">
            
                    
                    权限控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="keyboard.html">
            
                <a href="keyboard.html">
            
                    
                    小键盘
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="notification.html">
            
                <a href="notification.html">
            
                    
                    Notification
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">----安卓 foundation----</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="mvp.html">
            
                <a href="mvp.html">
            
                    
                    MVP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="rxjava.html">
            
                <a href="rxjava.html">
            
                    
                    RxJava
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="lang.html">
            
                <a href="lang.html">
            
                    
                    常用工具类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="http.html">
            
                <a href="http.html">
            
                    
                    http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="xml.html">
            
                <a href="xml.html">
            
                    
                    xml解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="json-reporter.html">
            
                <a href="json-reporter.html">
            
                    
                    Json解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="inject.html">
            
                <a href="inject.html">
            
                    
                    ButterKnife
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="thread.html">
            
                <a href="thread.html">
            
                    
                    安卓线程和looper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="process.html">
            
                <a href="process.html">
            
                    
                    多进程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="eventbus.html">
            
                <a href="eventbus.html">
            
                    
                    EventBus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="db.html">
            
                <a href="db.html">
            
                    
                    数据库和ContentProvider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="job.html">
            
                <a href="job.html">
            
                    
                    定时任务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.13" data-path="service.html">
            
                <a href="service.html">
            
                    
                    service
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.14" data-path="opt-mem.html">
            
                <a href="opt-mem.html">
            
                    
                    内存优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.15" data-path="opt-network.html">
            
                <a href="opt-network.html">
            
                    
                    网络优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.16" data-path="opt-anr.html">
            
                <a href="opt-anr.html">
            
                    
                    anr排查
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.17" data-path="opt-ui.html">
            
                <a href="opt-ui.html">
            
                    
                    UI卡顿优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.18" data-path="opt-launch.html">
            
                <a href="opt-launch.html">
            
                    
                    启动优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.19" data-path="opt-launch.html">
            
                <a href="opt-launch.html">
            
                    
                    混淆
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.20" data-path="hotfix.html">
            
                <a href="hotfix.html">
            
                    
                    热补丁混淆
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.21" data-path="aar.html">
            
                <a href="aar.html">
            
                    
                    aar相关
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.22" data-path="route.html">
            
                <a href="route.html">
            
                    
                    Route路由
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.23" data-path="modules.html">
            
                <a href="modules.html">
            
                    
                    分模块，组件化，插件化
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">----Gradle----</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="gradle.html">
            
                <a href="gradle.html">
            
                    
                    gradle基本配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="gradle-plugin.html">
            
                <a href="gradle-plugin.html">
            
                    
                    gradle插件开发
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">----工具----</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="repos.html">
            
                <a href="repos.html">
            
                    
                    优秀博客，开源项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="packs.html">
            
                <a href="packs.html">
            
                    
                    自动打包，多渠道打包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="gist.html">
            
                <a href="gist.html">
            
                    
                    代码片段和常见问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="stetho.html">
            
                <a href="stetho.html">
            
                    
                    stetho
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="fabric.html">
            
                <a href="fabric.html">
            
                    
                    fabric
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="app-update.html">
            
                <a href="app-update.html">
            
                    
                    自动升级
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="bugsnags.html">
            
                <a href="bugsnags.html">
            
                    
                    日志和崩溃统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="mail.html">
            
                <a href="mail.html">
            
                    
                    发邮件辅助接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="socail.html">
            
                <a href="socail.html">
            
                    
                    第三方登录和分享
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="pay-alipay.html">
            
                <a href="pay-alipay.html">
            
                    
                    支付宝支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="pay-wx.html">
            
                <a href="pay-wx.html">
            
                    
                    微信支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="umeng.html">
            
                <a href="umeng.html">
            
                    
                    友盟统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="push-jpush.html">
            
                <a href="push-jpush.html">
            
                    
                    推送-极光
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="push-xiaomi.html">
            
                <a href="push-xiaomi.html">
            
                    
                    推送-小米
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >TextView</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="textview">TextView</h1>
<h1 id="textview">TextView</h1>
<ul>
<li>&#x672C;&#x6587;&#x63A2;&#x8BA8;&#x7684;&#x662F;&#xFF1A;<ul>
<li>TextView&#x5230;&#x5E95;&#x80FD;&#x5C06;&#x6587;&#x672C;&#x663E;&#x793A;&#x5230;&#x4EC0;&#x4E48;&#x7A0B;&#x5EA6;</li>
<li>&#x5E38;&#x7528;&#x7684;&#x663E;&#x793A;&#x6A21;&#x5F0F;</li>
<li>&#x5B57;&#x4F53;</li>
<li>&#x4E00;&#x4E2A;&#x672A;&#x89E3;&#x51B3;&#x7684;bug&#xFF1A;TextView&#x663E;&#x793A;&#x8868;&#x60C5;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x9700;&#x8981;&#x9650;&#x5236;&#x5B57;&#x6570;&#x6216;&#x884C;&#x6570;&#xFF0C;&#x672B;&#x5C3E;&#x4EE5;&#x3002;&#x3002;&#x3002;&#x7ED3;&#x5C3E;&#xFF0C;&#x5982;&#x679C;&#x540E;&#x9762;&#x8FD8;&#x6709;&#x8868;&#x60C5;&#xFF0C;&#x5219;&#x8868;&#x60C5;&#x8FD8;&#x663E;&#x793A;&#xFF01;</li>
</ul>
</li>
</ul>
<h2 id="1-&#x663E;&#x793A;html"><a name="text">1 &#x663E;&#x793A;html</a></h2>
<p><strong>TextView&#x663E;&#x793A;html&#x6807;&#x7B7E;</strong></p>
<pre><code class="lang-java">Spanned s = Html.fromHtml(string);
tv_title.setText(s);
</code></pre>
<p><strong>&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;</strong>
    &#x9ED8;&#x8BA4;&#x652F;&#x6301;&#x7684;&#x6807;&#x7B7E;&#xFF1A;&#x53C2;&#x8003;android.text.Html&#x6E90;&#x7801;&#x7684;handleStartTag&#x65B9;&#x6CD5;</p>
<ul>
<li>&#x6807;&#x7B7E;&#x7684;&#x5904;&#x7406;&#x5176;&#x5B9E;&#x6D89;&#x53CA;&#x5230;&#x4E86;&#xFF1A;<ul>
<li>TextView&#xFF0C;Html&#xFF0C; Html.TagHandler&#x7B49;&#x63A5;&#x53E3;&#x7684;&#x4F7F;&#x7528;</li>
<li>xml&#x5904;&#x7406;&#xFF1A;&#x5904;&#x7406;html&#x6807;&#x7B7E;&#x6587;&#x672C;&#xFF0C;&#x4E3B;&#x8981;&#x662F;&#x622A;&#x53D6;&#x51FA;html&#x5305;&#x542B;&#x7684;&#x6587;&#x672C;&#xFF0C;&#x5C5E;&#x6027;&#x7B49;</li>
<li>&#x4F7F;&#x7528;SpannabeString&#x7684;setSpan&#x65B9;&#x6CD5;&#xFF0C;&#x914D;&#x5408;&#x5404;&#x79CD;span&#xFF0C;&#x5173;&#x4E8E;span&#x53C2;&#x8003;&#x4E0B;&#x4E00;&#x8282;</li>
</ul>
</li>
</ul>
<p>&#x5173;&#x4E8E;TagHandler&#x7684;&#x7528;&#x6CD5;&#xFF0C;&#x53EF;&#x4EE5;&#x53C2;&#x8003;demo&#x4E2D;&#x7684;MxgsaTagHandler&#x548C;HtmlHandlerActivity&#x8FD9;&#x4E24;&#x4E2A;&#x7C7B;</p>
<p>&#x53C2;&#x8003;&#x6587;&#x7AE0;&#xFF1A;<a href="http://www.cnblogs.com/mxgsa/archive/2012/11/15/2760256.html" target="_blank">http://www.cnblogs.com/mxgsa/archive/2012/11/15/2760256.html</a></p>
<pre><code class="lang-java">
<span class="hljs-comment">///&#x8FD9;&#x4E2A;&#x4F8B;&#x5B50;&#x662F;&#x4E00;&#x4E2A;&#x8D85;&#x94FE;&#x63A5;&#x663E;&#x793A;&#xFF0C;&#x5B9A;&#x4E49;&#x4E86;&#x4E00;&#x4E2A;mxgsa&#x6807;&#x7B7E;&#xFF0C;&#x5C06;&#x5305;&#x88F9;&#x7684;&#x6587;&#x672C;&#x663E;&#x793A;&#x4E3A;&#x8D85;&#x94FE;&#x63A5;&#xFF0C;&#x5E76;&#x4E14;&#x53EF;&#x4EE5;&#x70B9;&#x51FB;</span>

<span class="hljs-keyword">import</span> org.xml.sax.XMLReader;

<span class="hljs-keyword">import</span> android.content.Context;
<span class="hljs-keyword">import</span> android.content.Intent;
<span class="hljs-keyword">import</span> android.text.Editable;
<span class="hljs-keyword">import</span> android.text.Html.TagHandler;
<span class="hljs-keyword">import</span> android.text.Spanned;
<span class="hljs-keyword">import</span> android.text.style.ClickableSpan;
<span class="hljs-keyword">import</span> android.view.View;
<span class="hljs-keyword">import</span> android.view.View.OnClickListener;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MxgsaTagHandler</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">TagHandler</span></span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">int</span> sIndex = <span class="hljs-number">0</span>;
    <span class="hljs-keyword">private</span>  <span class="hljs-keyword">int</span> eIndex=<span class="hljs-number">0</span>;
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> Context mContext;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">MxgsaTagHandler</span><span class="hljs-params">(Context context)</span></span>{
        mContext=context;
    }

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handleTag</span><span class="hljs-params">(<span class="hljs-keyword">boolean</span> opening, String tag, Editable output, XMLReader xmlReader)</span> </span>{
        <span class="hljs-comment">//&#x8FD9;&#x91CC;&#x8981;&#x505A;&#x7684;&#x5DE5;&#x4F5C;&#x5C31;&#x662F;&#x5904;&#x7406;tag&#x6807;&#x7B7E;&#x5305;&#x88F9;&#x7684;&#x6587;&#x672C;output</span>
        <span class="hljs-comment">//xmlReader&#x91CC;&#x9762;&#x662F;&#x4EC0;&#x4E48;&#x8FD8;&#x4E0D;&#x6E05;&#x695A;</span>
        <span class="hljs-keyword">if</span> (tag.toLowerCase().equals(<span class="hljs-string">&quot;mxgsa&quot;</span>)) {
            <span class="hljs-keyword">if</span> (opening) {
                sIndex=output.length();
            }<span class="hljs-keyword">else</span> {
                eIndex=output.length();
                output.setSpan(<span class="hljs-keyword">new</span> MxgsaSpan(), sIndex, eIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
    }
    <span class="hljs-keyword">private</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MxgsaSpan</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">ClickableSpan</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">OnClickListener</span></span>{
        <span class="hljs-meta">@Override</span>
        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onClick</span><span class="hljs-params">(View widget)</span> </span>{
            <span class="hljs-comment">// TODO Auto-generated method stub</span>
            <span class="hljs-comment">//&#x5177;&#x4F53;&#x4EE3;&#x7801;&#xFF0C;&#x53EF;&#x4EE5;&#x662F;&#x8DF3;&#x8F6C;&#x9875;&#x9762;&#xFF0C;&#x53EF;&#x4EE5;&#x662F;&#x5F39;&#x51FA;&#x5BF9;&#x8BDD;&#x6846;&#xFF0C;&#x4E0B;&#x9762;&#x662F;&#x8DF3;&#x8F6C;&#x9875;&#x9762;</span>
            mContext.startActivity(<span class="hljs-keyword">new</span> Intent(mContext,MainActivity.class));
        }
    }

}
</code></pre>
<pre><code class="lang-java"><span class="hljs-comment">///&#x4F7F;&#x7528;mxgsa&#x6807;&#x7B7E;&#xFF1A;</span>
<span class="hljs-keyword">final</span> String txt = <span class="hljs-string">&quot;&#x6D4B;&#x8BD5;&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#xFF1A;&lt;br&gt;&lt;h1&gt;&lt;mxgsa&gt;&#x6D4B;&#x8BD5;&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&lt;/mxgsa&gt;&lt;/h1&gt;&quot;</span>;
tv.setText(Html.fromHtml(txt, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">new</span> MxgsaTagHandler(<span class="hljs-keyword">this</span>)));
tv.setClickable(<span class="hljs-keyword">true</span>);
tv.setMovementMethod(LinkMovementMethod.getInstance());  <span class="hljs-comment">//&#x60F3;&#x8BA9;&#x6807;&#x7B7E;&#x53EF;&#x70B9;&#x51FB;&#xFF0C;&#x5FC5;&#x987B;&#x8C03;&#x7528;&#x8FD9;&#x4E2A;</span>
</code></pre>
<pre><code class="lang-java"><span class="hljs-comment">//&#x4E0B;&#x9762;&#x518D;&#x7ED9;&#x51FA;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x63A2;&#x8BA8;handleTag&#x5230;&#x5E95;&#x600E;&#x4E48;&#x88AB;&#x8C03;&#x7528;&#xFF0C;html&#x6807;&#x7B7E;&#x5230;&#x5E95;&#x600E;&#x4E48;&#x89E3;&#x6790;</span>

<span class="hljs-comment">/**
 *  &#x539F;&#x6587;&#x662F;&#xFF1A;&lt;span style=&quot;{color:#e60012}&quot;&gt;&#x54C8;&#x54C8;&#x54C8;&lt;/span&gt;&#xFF1A;
 *  html--&#x7B2C;1&#x6B21;&#x8FDB;&#x6765;&#xFF0C;opening=true, output=, tag=html
 *  html--&#x7B2C;2&#x6B21;&#x8FDB;&#x6765;&#xFF0C;opening=true, output=, tag=body
 *  html--&#x7B2C;3&#x6B21;&#x8FDB;&#x6765;&#xFF0C;opening=true, output=, tag=span           ---
 *  html--&#x7B2C;4&#x6B21;&#x8FDB;&#x6765;&#xFF0C;opening=false, output=&#x54C8;&#x54C8;&#x54C8;, tag=span     ---
 *  html--&#x7B2C;5&#x6B21;&#x8FDB;&#x6765;&#xFF0C;opening=false, output=&#x54C8;&#x54C8;&#x54C8;, tag=body
 *  html--&#x7B2C;6&#x6B21;&#x8FDB;&#x6765;&#xFF0C;opening=false, output=&#x54C8;&#x54C8;&#x54C8;, tag=html
 * <span class="hljs-doctag">@param</span> opening
 * <span class="hljs-doctag">@param</span> tag
 * <span class="hljs-doctag">@param</span> output
 * <span class="hljs-doctag">@param</span> xmlReader
 */</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handleTag</span><span class="hljs-params">(<span class="hljs-keyword">boolean</span> opening, String tag, Editable output, XMLReader xmlReader)</span> </span>{
    count++;
    JLog.i(<span class="hljs-string">&quot;html&quot;</span>, <span class="hljs-string">&quot;html--&#x7B2C;&quot;</span> + count + <span class="hljs-string">&quot;&#x6B21;&#x8FDB;&#x6765;&#xFF0C;opening=&quot;</span> + opening + <span class="hljs-string">&quot;, output=&quot;</span> + output + <span class="hljs-string">&quot;, tag=&quot;</span> + tag);
    <span class="hljs-keyword">if</span> (tag.toLowerCase().equals(<span class="hljs-string">&quot;span&quot;</span>)) {
        <span class="hljs-keyword">if</span> (opening) {
            sIndex = output.length();
        }<span class="hljs-keyword">else</span> {
            eIndex = output.length();
            output.setSpan(<span class="hljs-keyword">new</span> MxgsaSpan(), sIndex, eIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
}


<span class="hljs-comment">////&#x73B0;&#x5728;&#x5C1D;&#x8BD5;&#x4F7F;&#x7528;XmlReader&#x8BFB;&#x51FA;span&#x7684;&#x5C5E;&#x6027;style&#xFF0C;&#x83B7;&#x53D6;&#x5176;&#x4E2D;&#x7684;color</span>
<span class="hljs-comment">//&#x95EE;&#x9898;&#x662F;&#xFF0C;&#x73B0;&#x5728;handleTag&#x53EA;&#x8FDB;&#x4E00;&#x6B21;&#x4E86;&#xFF0C;&#x800C;&#x4E14;output&#x662F;&#x7A7A;</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">handleTag</span><span class="hljs-params">(<span class="hljs-keyword">boolean</span> opening, String tag, Editable output, XMLReader xmlReader)</span> </span>{
    count++;
    JLog.i(<span class="hljs-string">&quot;html&quot;</span>, <span class="hljs-string">&quot;html--&#x7B2C;&quot;</span> + count + <span class="hljs-string">&quot;&#x6B21;&#x8FDB;&#x6765;&#xFF0C;opening=&quot;</span> + opening + <span class="hljs-string">&quot;, output=&quot;</span> + output + <span class="hljs-string">&quot;, tag=&quot;</span> + tag);

    <span class="hljs-comment">//&#x5982;&#x679C;&#x5728;&#x8FD9;&#x91CC;&#x76F4;&#x63A5;&#x7528;XmlReader&#x89E3;&#x6790;&#xFF0C;&#x4E5F;&#x6CA1;&#x6709;&#x89E3;&#x6790;&#x591A;&#x6B21;&#xFF1F;&#xFF1F;&#x6BD4;&#x8F83;&#x5947;&#x602A;&#xFF0C;&#x8FD8;&#x662F;&#x53BB;&#x770B;&#x770B;&#x6E90;&#x7801;&#x5427;</span>
    <span class="hljs-keyword">if</span>(count == <span class="hljs-number">1</span>){
        xmlReader.setContentHandler(<span class="hljs-keyword">new</span> XMLContentHandler());
    }<span class="hljs-keyword">else</span>{
        xmlReader.setContentHandler(<span class="hljs-keyword">null</span>);
    }

    <span class="hljs-keyword">if</span> (tag.toLowerCase().equals(<span class="hljs-string">&quot;span&quot;</span>)) {
        <span class="hljs-keyword">if</span> (opening) {
            sIndex = output.length();
            <span class="hljs-comment">//&#x5982;&#x679C;&#x5728;&#x8FD9;&#x91CC;&#x7528;XmlReader&#x89E3;&#x6790;&#xFF0C;&#x5DF2;&#x7ECF;&#x8FC7;&#x4E86;&lt;span&gt;&#x6807;&#x7B7E;&#x7684;&#x5F00;&#x59CB;&#x4E86;&#xFF0C;&#x597D;&#x50CF;&#x662F;&#x89E3;&#x6790;&#x7684;&#x8FD9;&#x90E8;&#x5206;&#xFF1A;&#x54C8;&#x54C8;&#x54C8;&lt;/span&gt;</span>
        }<span class="hljs-keyword">else</span> {
            eIndex = output.length();
            <span class="hljs-keyword">if</span>(fontColor == <span class="hljs-keyword">null</span> || fontColor.equals(<span class="hljs-string">&quot;&quot;</span>)){
                fontColor = <span class="hljs-string">&quot;#000000&quot;</span>;
            }<span class="hljs-keyword">else</span>{

            }
            JLog.i(<span class="hljs-string">&quot;html&quot;</span>, <span class="hljs-string">&quot;html--&#x7B2C;&quot;</span> + count + <span class="hljs-string">&quot;&#x6B21;&#x8FDB;&#x6765;&#xFF0C;fontColor = &quot;</span> + fontColor);
            output.setSpan(<span class="hljs-keyword">new</span> ForegroundColorSpan(Color.parseColor(fontColor)), sIndex, eIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }


    }
}

<span class="hljs-keyword">private</span> String fontColor = <span class="hljs-string">&quot;&quot;</span>;
<span class="hljs-comment">//    private String output = &quot;&quot;;</span>
<span class="hljs-comment">//    private int startIndex = 0;</span>
<span class="hljs-comment">//    private int endIndex = 0;</span>

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">XMLContentHandler</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">DefaultHandler</span> </span>{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">final</span> String TAG = <span class="hljs-string">&quot;XMLContentHandler&quot;</span>;

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">characters</span><span class="hljs-params">(<span class="hljs-keyword">char</span>[] ch, <span class="hljs-keyword">int</span> start, <span class="hljs-keyword">int</span> length)</span>
            <span class="hljs-keyword">throws</span> SAXException </span>{
        Log.i(TAG, <span class="hljs-string">&quot;&#x89E3;&#x6790;&#x5185;&#x5BB9;&#xFF1A;&quot;</span> + <span class="hljs-keyword">new</span> String(ch, start, length));
    }
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">endDocument</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> SAXException </span>{
        <span class="hljs-keyword">super</span>.endDocument();
        Log.i(TAG, <span class="hljs-string">&quot;&#x6587;&#x6863;&#x89E3;&#x6790;&#x5B8C;&#x6BD5;&#x3002;&quot;</span>);
    }
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">endElement</span><span class="hljs-params">(String uri, String localName, String qName)</span>
            <span class="hljs-keyword">throws</span> SAXException </span>{
        Log.i(TAG, localName+<span class="hljs-string">&quot;&#x89E3;&#x6790;&#x5B8C;&#x6BD5;&quot;</span>);
    }
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">startDocument</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> SAXException </span>{
        Log.i(TAG, <span class="hljs-string">&quot;&#x5F00;&#x59CB;&#x89E3;&#x6790;... ...&quot;</span>);
    }
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">startElement</span><span class="hljs-params">(String uri, String localName, String qName,
                             Attributes attributes)</span> <span class="hljs-keyword">throws</span> SAXException </span>{
        Log.i(TAG, <span class="hljs-string">&quot;&#x89E3;&#x6790;&#x5143;&#x7D20;&#xFF1A;&quot;</span>+localName);

        <span class="hljs-keyword">if</span>(localName.equals(<span class="hljs-string">&quot;span&quot;</span>)){
            Log.i(TAG, <span class="hljs-string">&quot;&#x89E3;&#x6790;&#x5143;&#x7D20;&#xFF1A;&quot;</span>+localName);
            <span class="hljs-keyword">if</span>(attributes != <span class="hljs-keyword">null</span>){
                <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i = <span class="hljs-number">0</span>; i &lt; attributes.getLength(); i++){
                    Log.i(TAG, <span class="hljs-string">&quot;====&quot;</span> + attributes.getLocalName(i) + <span class="hljs-string">&quot;: &quot;</span> + attributes.getQName(i) + <span class="hljs-string">&quot;: &quot;</span> + attributes.getValue(i));
                    <span class="hljs-keyword">if</span>(attributes.getLocalName(i).equals(<span class="hljs-string">&quot;style&quot;</span>)){
                        String style = attributes.getValue(i); <span class="hljs-comment">//{color:#e60012}</span>
                        fontColor = style.replace(<span class="hljs-string">&quot;{&quot;</span>, <span class="hljs-string">&quot;&quot;</span>).replace(<span class="hljs-string">&quot;}&quot;</span>, <span class="hljs-string">&quot;&quot;</span>).replace(<span class="hljs-string">&quot;color&quot;</span>, <span class="hljs-string">&quot;&quot;</span>).replace(<span class="hljs-string">&quot;:&quot;</span>, <span class="hljs-string">&quot;&quot;</span>);
                        Log.i(TAG, <span class="hljs-string">&quot;fontColor=&quot;</span> + fontColor);
                    }
                }
            }
        }
    }
}
</code></pre>
<h2 id="&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#x7684;&#x66FF;&#x4EE3;&#x65B9;&#x6848;"><a name="custom_expand">&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#x7684;&#x66FF;&#x4EE3;&#x65B9;&#x6848;</a></h2>
<p><strong>&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#x6269;&#x5C55;</strong></p>
<pre><code>&#x5B89;&#x5353;&#x63D0;&#x4F9B;&#x7684;&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#x7684;&#x7591;&#x95EE;&#xFF1A;
&#x4E0D;&#x77E5;&#x9053;&#x600E;&#x4E48;&#x62FF;&#x5230;&#x6807;&#x7B7E;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x4F8B;&#x5982;&#x89E3;&#x6790;&lt;span style=&quot;{color:#e60012}&quot;&gt;&#x54C8;&#x54C8;&#x54C8;&lt;/span&gt;
</code></pre><p><strong>Ayo&#x5E93;&#x63D0;&#x4F9B;&#x4E86;&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#x7684;&#x66FF;&#x4EE3;&#x65B9;&#x6848;:</strong></p>
<p>&#x53EF;&#x4EE5;&#x53C2;&#x8003;&#x8FD9;&#x4E2A;&#x5DE5;&#x7A0B;&#xFF1A;<a href="https://github.com/cowthan/HtmlTagHandler" target="_blank">HtmlTagHandler</a></p>
<p>&#x5DF2;&#x7ECF;&#x6574;&#x5408;&#x5230;Ayo&#x5E93;&#x4E2D;&#x4E86;</p>
<h2 id="2-spannable&#x5230;&#x5E95;&#x600E;&#x4E48;&#x7528;">2 spannable&#x5230;&#x5E95;&#x600E;&#x4E48;&#x7528;</h2>
<p>&#x4E00;&#x6BB5;&#x6587;&#x672C;&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x591A;&#x79CD;&#x6587;&#x672C;&#x683C;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;spannable&#x5BF9;&#x5404;&#x6BB5;&#x6587;&#x672C;&#x8BBE;&#x7F6E;&#x4E0D;&#x540C;&#x683C;&#x5F0F;</p>
<p>&#x5148;&#x7ED9;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x8FD9;&#x4E2A;&#x5982;&#x4F55;&#x5B9E;&#x73B0;&#xFF1F;</p>
<p><img src="http://7xo0ny.com1.z0.glb.clouddn.com/ayo_v_tv_1.png" alt=""></p>
<pre><code class="lang-java"><span class="hljs-comment">//&#x4F7F;&#x7528;Spannable</span>
String content = <span class="hljs-string">&quot;&#x76EE;&#x524D;&#x6709;{numHospital}&#x5BB6;&#x533B;&#x9662;{numSeller}&#x4F4D;&#x54A8;&#x8BE2;&#x5E08;&quot;</span>;
content = content.replace(<span class="hljs-string">&quot;{numHospital}&quot;</span>, info.hospitalNum).replace(<span class="hljs-string">&quot;{numSeller}&quot;</span>, info.zxsNum);
Spanned s = Html.fromHtml(content);
<span class="hljs-keyword">int</span> index0 = content.indexOf(<span class="hljs-string">&quot;&#x524D;&#x6709;&quot;</span>)+<span class="hljs-number">2</span>;
<span class="hljs-keyword">int</span> index1 = content.indexOf(<span class="hljs-string">&quot;&#x5BB6;&#x533B;&#x9662;&quot;</span>) + <span class="hljs-number">3</span>;
<span class="hljs-keyword">int</span> index2 = content.indexOf(<span class="hljs-string">&quot;&#x4F4D;&#x54A8;&quot;</span>);

msp = <span class="hljs-keyword">new</span> SpannableString(s);
msp.setSpan(<span class="hljs-keyword">new</span> RelativeSizeSpan(<span class="hljs-number">1.25f</span>), index0, index1-<span class="hljs-number">3</span>, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  <span class="hljs-comment">//0.5f&#x8868;&#x793A;&#x9ED8;&#x8BA4;&#x5B57;&#x4F53;&#x5927;&#x5C0F;&#x7684;&#x4E00;&#x534A;  </span>
msp.setSpan(<span class="hljs-keyword">new</span> RelativeSizeSpan(<span class="hljs-number">1.2f</span>), index1,index2 , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  <span class="hljs-comment">//0.5f&#x8868;&#x793A;&#x9ED8;&#x8BA4;&#x5B57;&#x4F53;&#x5927;&#x5C0F;&#x7684;&#x4E00;&#x534A;  </span>
msp.setSpan(<span class="hljs-keyword">new</span> ForegroundColorSpan(Color.parseColor(color)), index0, index1-<span class="hljs-number">3</span>,  Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  <span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x524D;&#x666F;&#x8272;  </span>
msp.setSpan(<span class="hljs-keyword">new</span> ForegroundColorSpan(Color.parseColor(color)),index1,index2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  <span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x524D;&#x666F;&#x8272; </span>
msp.setSpan(<span class="hljs-keyword">new</span> StyleSpan(android.graphics.Typeface.ITALIC), index0, index1-<span class="hljs-number">3</span>, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  <span class="hljs-comment">//&#x659C;&#x4F53;  </span>
msp.setSpan(<span class="hljs-keyword">new</span> StyleSpan(android.graphics.Typeface.ITALIC), index1,index2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);  <span class="hljs-comment">//&#x659C;&#x4F53;  </span>
msp.setSpan(<span class="hljs-keyword">new</span> ScaleXSpan(<span class="hljs-number">0.9f</span>), index0, index1-<span class="hljs-number">3</span>, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
msp.setSpan(<span class="hljs-keyword">new</span> ScaleXSpan(<span class="hljs-number">0.9f</span>), index1,index2 , Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tv_info.setText(msp);
</code></pre>
<h4 id="">#</h4>
<ul>
<li>&#x5148;&#x8BF4;setSpan&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#xFF1A;Spanned.SPAN_EXCLUSIVE_EXCLUSIVE<ul>
<li>&#x662F;&#x7528;&#x6765;&#x6807;&#x8BC6;&#x5728; Span &#x8303;&#x56F4;&#x5185;&#x7684;&#x6587;&#x672C;&#x524D;&#x540E;&#x8F93;&#x5165;&#x65B0;&#x7684;&#x5B57;&#x7B26;&#x65F6;&#x662F;&#x5426;&#x628A;&#x5B83;&#x4EEC;&#x4E5F;&#x5E94;&#x7528;&#x8FD9;&#x4E2A;&#x6548;&#x679C;</li>
<li>Spanned.SPAN_EXCLUSIVE_EXCLUSIVE(&#x524D;&#x540E;&#x90FD;&#x4E0D;&#x5305;&#x62EC;)</li>
<li>Spanned.SPAN_INCLUSIVE_EXCLUSIVE(&#x524D;&#x9762;&#x5305;&#x62EC;&#xFF0C;&#x540E;&#x9762;&#x4E0D;&#x5305;&#x62EC;)</li>
<li>Spanned.SPAN_EXCLUSIVE_INCLUSIVE(&#x524D;&#x9762;&#x4E0D;&#x5305;&#x62EC;&#xFF0C;&#x540E;&#x9762;&#x5305;&#x62EC;)</li>
<li>Spanned.SPAN_INCLUSIVE_INCLUSIVE(&#x524D;&#x540E;&#x90FD;&#x5305;&#x62EC;)</li>
</ul>
</li>
</ul>
<h4 id="">#</h4>
<p>TextView&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x7684;&#x663E;&#x793A;&#x6837;&#x5F0F;&#xFF1A;</p>
<p><img src="http://7xo0ny.com1.z0.glb.clouddn.com/ayo_368eff70-10ae-393c-8e00-e94ee213c1a2.png" alt=""></p>
<ul>
<li><p>&#x5B57;&#x4F53;&#xFF1A;TypefaceSpan</p>
<ul>
<li>TypefaceSpan(&quot;monospace&quot;)</li>
<li>&#x5B57;&#x4F53;&#x6709;&#xFF1A;default,default-bold,monospace,serif,sans-serif</li>
</ul>
</li>
<li><p>&#x5B57;&#x4F53;&#x6837;&#x5F0F;&#xFF1A;StyleSpan</p>
<ul>
<li>android.graphics.Typeface.NORMAL</li>
<li>android.graphics.Typeface.BOLD</li>
<li>android.graphics.Typeface.ITALIC</li>
<li>android.graphics.Typeface.BOLD_ITALIC</li>
</ul>
</li>
<li><p>&#x5B57;&#x4F53;&#x5927;&#x5C0F;&#xFF1A;</p>
<ul>
<li>&#x7EDD;&#x5BF9;&#x5927;&#x5C0F;&#xFF0C;&#x5355;&#x4F4D;&#x50CF;&#x7D20;&#xFF1A;AbsoluteSizeSpan(20)</li>
<li>&#x76F8;&#x5BF9;&#x5927;&#x5C0F;&#xFF0C;&#x6307;&#x5B9A;&#x9ED8;&#x8BA4;&#x5B57;&#x4F53;&#x5927;&#x5C0F;&#x7684;&#x591A;&#x5C11;&#x500D;&#xFF1A;RelativeSizeSpan</li>
<li>&#x7F29;&#x653E;&#xFF1A;ScaleXSpan&#xFF0C;&#x8868;&#x793A;&#x4E3A;&#x9ED8;&#x8BA4;&#x5B57;&#x4F53;&#x5BBD;&#x5EA6;&#x7684;&#x591A;&#x5C11;&#x500D;</li>
</ul>
</li>
<li><p>&#x5B57;&#x4F53;&#x989C;&#x8272;&#xFF1A;</p>
<ul>
<li>&#x524D;&#x666F;&#x8272;&#xFF1A;ForegroundColorSpan(Color.MAGENTA)</li>
<li>&#x80CC;&#x666F;&#x8272;&#xFF1A;BackgroundColorSpan(Color.CYAN)</li>
</ul>
</li>
<li><p>&#x5B57;&#x4F53;&#x7EFC;&#x5408;&#xFF1A;TextAppearanceSpan</p>
<ul>
<li>&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x5B57;&#x4F53;&#xFF0C;&#x6837;&#x5F0F;&#xFF0C;&#x5927;&#x5C0F;&#xFF0C;&#x989C;&#x8272;&#x7B49;</li>
</ul>
</li>
</ul>
<pre><code class="lang-java"><span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x5B57;&#x4F53;&#xFF08;&#x4F9D;&#x6B21;&#x5305;&#x62EC;&#x5B57;&#x4F53;&#x540D;&#x79F0;&#xFF0C;&#x5B57;&#x4F53;&#x5927;&#x5C0F;&#xFF0C;&#x5B57;&#x4F53;&#x6837;&#x5F0F;&#xFF0C;&#x5B57;&#x4F53;&#x989C;&#x8272;&#xFF0C;&#x94FE;&#x63A5;&#x989C;&#x8272;&#xFF09;</span>
ColorStateList csllink = <span class="hljs-keyword">null</span>;
ColorStateList csl = <span class="hljs-keyword">null</span>;
XmlResourceParser xppcolor=getResources().getXml (R.color.color);
<span class="hljs-keyword">try</span> {
    csl= ColorStateList.createFromXml(getResources(),xppcolor);
}<span class="hljs-keyword">catch</span>(XmlPullParserException e){
    <span class="hljs-comment">// <span class="hljs-doctag">TODO:</span> handle exception</span>
    e.printStackTrace();
}<span class="hljs-keyword">catch</span>(IOException e){
    <span class="hljs-comment">// <span class="hljs-doctag">TODO:</span> handle exception</span>
    e.printStackTrace();
}

XmlResourceParser xpplinkcolor=getResources().getXml(R.color.linkcolor);
<span class="hljs-keyword">try</span> {
    csllink= ColorStateList.createFromXml(getResources(),xpplinkcolor);
}<span class="hljs-keyword">catch</span>(XmlPullParserException e){
    <span class="hljs-comment">// <span class="hljs-doctag">TODO:</span> handle exception</span>
    e.printStackTrace();
}<span class="hljs-keyword">catch</span>(IOException e){
    <span class="hljs-comment">// <span class="hljs-doctag">TODO:</span> handle exception</span>
    e.printStackTrace();
}
msp.setSpan(<span class="hljs-keyword">new</span> TextAppearanceSpan(<span class="hljs-string">&quot;monospace&quot;</span>,android.graphics.Typeface.BOLD_ITALIC, <span class="hljs-number">30</span>, csl, csllink), <span class="hljs-number">51</span>, <span class="hljs-number">53</span>, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
</code></pre>
<ul>
<li><p>&#x5404;&#x79CD;&#x7EBF;&#xFF1A;</p>
<ul>
<li>&#x4E0B;&#x5212;&#x7EBF;&#xFF1A;UnderlineSpan</li>
<li>&#x5220;&#x9664;&#x7EBF;&#xFF1A;StrikethroughSpan</li>
</ul>
</li>
<li><p>&#x4E0A;&#x6807;&#x4E0B;&#x6807;&#xFF1A;</p>
<ul>
<li>&#x4E0B;&#x6807;&#xFF1A;SubscriptSpan</li>
<li>&#x4E0A;&#x6807;&#xFF1A;SuperscriptSpan</li>
</ul>
</li>
<li><p>&#x8D85;&#x94FE;&#x63A5;&#xFF1A;</p>
<ul>
<li>&#x7535;&#x8BDD;&#xFF1A;URLSpan(&quot;tel:4155551212&quot;)</li>
<li>&#x90AE;&#x4EF6;&#xFF1A;URLSpan(&quot;mailto:webmaster@google.com&quot;)</li>
<li>&#x7F51;&#x9875;&#xFF1A;URLSpan(&quot;<a href="http://www.baidu.com" target="_blank">http://www.baidu.com</a>&quot;)</li>
<li>&#x77ED;&#x4FE1;&#xFF1A;URLSpan(&quot;sms:4155551212&quot;)&#xFF0C;&#x6216;&#x8005;smsto</li>
<li>&#x5730;&#x56FE;&#xFF1A;URLSpan(&quot;geo:38.899533,-77.036476&quot;)</li>
</ul>
</li>
</ul>
<ul>
<li>&#x9879;&#x76EE;&#x7B26;&#x53F7;<ul>
<li>BulletSpan</li>
</ul>
</li>
</ul>
<pre><code class="lang-java"><span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x9879;&#x76EE;&#x7B26;&#x53F7;</span>
msp.setSpan(<span class="hljs-keyword">new</span> BulletSpan(android.text.style.BulletSpan.STANDARD_GAP_WIDTH,Color.GREEN), <span class="hljs-number">0</span> ,msp.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); <span class="hljs-comment">//&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x8868;&#x793A;&#x9879;&#x76EE;&#x7B26;&#x53F7;&#x5360;&#x7528;&#x7684;&#x5BBD;&#x5EA6;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x4E3A;&#x9879;&#x76EE;&#x7B26;&#x53F7;&#x7684;&#x989C;&#x8272;</span>
</code></pre>
<ul>
<li>&#x8BBE;&#x7F6E;&#x56FE;&#x7247;<ul>
<li>ImageSpan</li>
</ul>
</li>
</ul>
<pre><code class="lang-java"><span class="hljs-comment">//&#x8BBE;&#x7F6E;&#x56FE;&#x7247;</span>
Drawable drawable = getResources().getDrawable(R.drawable.icon);
drawable.setBounds(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
msp.setSpan(<span class="hljs-keyword">new</span> ImageSpan(drawable), <span class="hljs-number">53</span>, <span class="hljs-number">57</span>, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

mTextView.setText(msp);
mTextView.setMovementMethod(LinkMovementMethod.getInstance());
</code></pre>
<h2 id="3-awesometextview">3 AwesomeTextView</h2>
<p>&#x4E00;&#x6BB5;&#x6587;&#x672C;&#x4E2D;&#xFF0C;&#x5982;&#x679C;&#x6709;&#x591A;&#x79CD;&#x6587;&#x672C;&#x683C;&#x5F0F;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;AwesomeTextView&#x5BF9;&#x5404;&#x6BB5;&#x6587;&#x672C;&#x8BBE;&#x7F6E;&#x4E0D;&#x540C;&#x683C;&#x5F0F;</p>
<p>&#x5176;&#x5185;&#x90E8;&#x5B9E;&#x73B0;&#x7528;&#x5230;&#x4E86;&#x5C06;view&#x8F6C;&#x4E3A;bitmap&#xFF0C;&#x53EF;&#x80FD;&#x5B58;&#x5728;&#x6027;&#x80FD;&#x4E0A;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x4F46;&#x80FD;&#x505A;&#x5230;&#x7684;&#x4E8B;&#x80AF;&#x5B9A;&#x6BD4;spannable&#x591A;</p>
<pre><code class="lang-java">String amount = content.getAmount();
viewHolder.tv_amount.setText(<span class="hljs-string">&quot;&#xFFE5;&quot;</span> + amount);
<span class="hljs-keyword">if</span>(SB.common.isNotEmpty(amount)){
       AwesomeTextHandler awesomeTextViewHandler = <span class="hljs-keyword">new</span> AwesomeTextHandler();
    awesomeTextViewHandler
           .addViewSpanRenderer(amount, <span class="hljs-keyword">new</span> CardAmountSpanRenderer())
        .setView(viewHolder.tv_amount);
}

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CardAmountSpanRenderer</span> <span class="hljs-keyword">implements</span> <span class="hljs-title">AwesomeTextHandler</span>.<span class="hljs-title">ViewSpanRenderer</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">int</span> textSizeInDips = <span class="hljs-number">20</span>;

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> View <span class="hljs-title">getView</span><span class="hljs-params">(String text, Context context)</span> </span>{
        TextView view = <span class="hljs-keyword">new</span> TextView(context);
        view.setTextColor(Color.parseColor(<span class="hljs-string">&quot;#ff8d84&quot;</span>));
        view.setTextSize(SB.display.sp2px(App.app, <span class="hljs-number">20</span>));
        SpannableString  ss = <span class="hljs-keyword">new</span> SpannableString(text);
        view.setText(ss);
        <span class="hljs-keyword">return</span> view;
    }
}
</code></pre>
<ul>
<li>&#x6CE8;&#x610F;addViewSpanRenderer<ul>
<li>&#x53C2;&#x6570;1&#x53EF;&#x4EE5;&#x662F;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x544A;&#x8BC9;renderer&#x6E32;&#x67D3;&#x54EA;&#x6BB5;&#x6587;&#x672C;</li>
<li>&#x53C2;&#x6570;2&#x662F;&#x4E2A;ViewSpanRenderer</li>
</ul>
</li>
</ul>
<h2 id="4-baggerview">4 BaggerView</h2>
<p>&#x6548;&#x679C;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><img src="http://7xo0ny.com1.z0.glb.clouddn.com/ayo_badgerview.png" alt=""></p>
<p>&#x672A;&#x8BFB;&#x6D88;&#x606F;&#x63D0;&#x793A;&#xFF0C;&#x4E2A;&#x4F4D;&#x6570;&#x65F6;&#x662F;&#x5706;&#xFF0C;&#x4E24;&#x4F4D;&#x6570;&#x6216;&#x8005;&#x66F4;&#x591A;&#x65F6;&#xFF0C;&#x662F;&#x77E9;&#x5F62;&#x5706;</p>
<p>&#x6765;&#x6E90;&#xFF1A;<a href="https://github.com/stefanjauker/BadgeView" target="_blank">https://github.com/stefanjauker/BadgeView</a></p>
<p>&#x6709;&#x4E2A;bug&#xFF1A;&#x534E;&#x4E3A;pad&#x4E0A;&#xFF0C;setTargetView&#x4E4B;&#x540E;&#xFF0C;&#x89D2;&#x6807;&#x8DD1;&#x540E;&#x8FB9;&#x53BB;&#x4E86;&#xFF0C;&#x5176;&#x4ED6;&#x624B;&#x673A;&#x90FD;&#x662F;&#x5728;&#x4E0A;&#x9762;&#x554A;&#x6211;&#x65E5;</p>
<p>&#x9ED8;&#x8BA4;&#x662F;&#x7EA2;&#x8272;&#xFF0C;&#x53EF;&#x4EE5;&#x4FEE;&#x6539;</p>
<pre><code class="lang-xml"><span class="hljs-tag">&lt;<span class="hljs-name">com.iwomedia.zhaoyang.widget.BadgeView</span>
        <span class="hljs-attr">android:id</span>=<span class="hljs-string">&quot;@+id/tv_unread_count&quot;</span>
        <span class="hljs-attr">android:layout_width</span>=<span class="hljs-string">&quot;15dp&quot;</span>
        <span class="hljs-attr">android:layout_height</span>=<span class="hljs-string">&quot;15dp&quot;</span>
        <span class="hljs-attr">android:textColor</span>=<span class="hljs-string">&quot;@android:color/white&quot;</span>
        <span class="hljs-attr">android:textSize</span>=<span class="hljs-string">&quot;10sp&quot;</span>
        /&gt;</span>
</code></pre>
<pre><code class="lang-java"><span class="hljs-comment">//&#x53EF;&#x4EE5;&#x5F53;TextView&#x4F7F;&#x7528;&#xFF1A;&#x9ED8;&#x8BA4;&#x662F;&#x7EA2;&#x5E95;&#x767D;&#x5B57;&#xFF0C;&#x7EA2;&#x5E95;&#x8FD8;&#x5E26;&#x70B9;&#x900F;&#x660E;&#xFF0C;&#x53EF;&#x4EE5;&#x5F53;&#x672A;&#x8BFB;&#x6D88;&#x606F;&#x7684;&#x5C0F;&#x7EA2;&#x70B9;&#x7528;</span>
BadgeView bagde = findViewById(R.id.tv_unread_count);
badge.setText(<span class="hljs-string">&quot;99+&quot;</span>);

<span class="hljs-comment">//&#x4F5C;&#x8005;&#x63D0;&#x4F9B;&#x4E86;&#x66F4;&#x591A;&#x529F;&#x80FD;&#xFF1A;&#x6709;demo</span>
BadgeView badge = <span class="hljs-keyword">new</span> BadgeView(getActivity());
badge.setTargetView(myView);
badge.setBadgeCount(<span class="hljs-number">42</span>);
</code></pre>
<h2 id="7-&#x5E7F;&#x544A;&#x6761;">7 &#x5E7F;&#x544A;&#x6761;</h2>
<p>&#x6765;&#x81EA;&#xFF1A;<a href="https://github.com/Rowandjj/VerticalBannerView" target="_blank">https://github.com/Rowandjj/VerticalBannerView</a></p>
<p>&#x6548;&#x679C;&#x5982;&#x4E0B;&#xFF1A;</p>
<p><img src="http://7xo0ny.com1.z0.glb.clouddn.com/ayo_verticalbannerview.gif" alt=""></p>
<ul>
<li>Feature<ul>
<li>&#x53EF;&#x81EA;&#x7531;&#x5B9A;&#x4E49;&#x5C55;&#x793A;&#x7684;&#x5185;&#x5BB9;</li>
<li>&#x4F7F;&#x7528;&#x65B9;&#x5F0F;&#x7C7B;&#x4F3C;ListView/RecyclerView</li>
<li>&#x53EF;&#x4E3A;&#x5F53;&#x524D;&#x7684;&#x5185;&#x5BB9;&#x6DFB;&#x52A0;&#x5404;&#x79CD;&#x4E8B;&#x4EF6;,&#x6BD4;&#x5982;&#x70B9;&#x51FB;&#x6253;&#x5F00;&#x67D0;&#x4E2A;&#x9875;&#x9762;&#x7B49;</li>
</ul>
</li>
</ul>
<p>&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x7C7B;&#x4F3C;ListView</p>
<ol>
<li><p>&#x5B9A;&#x4E49;item&#x7684;&#x5E03;&#x5C40;</p>
<pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
 &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
               android:orientation=&quot;vertical&quot;
               android:layout_width=&quot;match_parent&quot;
               android:background=&quot;#000&quot;
                 android:gravity=&quot;center_vertical&quot;
               android:layout_height=&quot;60dp&quot;&gt;

     &lt;ImageView
         android:layout_marginLeft=&quot;10dp&quot;
         android:id=&quot;@+id/iv&quot;
         android:src=&quot;@android:drawable/ic_dialog_email&quot;
         android:layout_width=&quot;30dp&quot;
         android:layout_height=&quot;30dp&quot;
         /&gt;

     &lt;TextView
         android:id=&quot;@+id/tv_02&quot;
         android:text=&quot;hello world&quot;
         android:layout_marginLeft=&quot;10dp&quot;
         android:textSize=&quot;16sp&quot;
         android:layout_toRightOf=&quot;@id/iv&quot;
         android:paddingLeft=&quot;5dp&quot;
         android:textColor=&quot;#fff&quot;
         android:layout_width=&quot;match_parent&quot;
         android:layout_height=&quot;wrap_content&quot;/&gt;

     &lt;TextView
         android:layout_below=&quot;@id/tv_02&quot;
         android:text=&quot;I am detail message......&quot;
         android:layout_marginLeft=&quot;10dp&quot;
         android:textSize=&quot;14sp&quot;
         android:layout_centerVertical=&quot;true&quot;
         android:layout_toRightOf=&quot;@id/iv&quot;
         android:paddingLeft=&quot;5dp&quot;
         android:textColor=&quot;#fff&quot;
         android:layout_width=&quot;match_parent&quot;
         android:layout_height=&quot;wrap_content&quot;/&gt;
 &lt;/RelativeLayout&gt;
</code></pre></li>
<li><p>&#x5B9E;&#x73B0;adapter</p>
<pre><code> public class SampleAdapter01 extends BaseBannerAdapter&lt;Model01&gt; {

     private List&lt;Model01&gt; mDatas;

     public SampleAdapter01(List&lt;Model01&gt; datas) {
         super(datas);
     }

     @Override
     public View getView(VerticalBannerView parent) {
         return LayoutInflater.from(parent.getContext()).inflate(R.layout.item_01,null);
     }

     @Override
     public void setItem(final View view, final Model01 data) {
         TextView tv = (TextView) view.findViewById(R.id.tv_01);
         tv.setText(data.title);
         //&#x4F60;&#x53EF;&#x4EE5;&#x589E;&#x52A0;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;
         view.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 //&#x6BD4;&#x5982;&#x6253;&#x5F00;url
                 Toast.makeText(view.getContext(),data.url,Toast.LENGTH_SHORT).show();
             }
         });
     }
 }
</code></pre></li>
<li><p>&#x5728;&#x5E03;&#x5C40;&#x4E2D;&#x589E;&#x52A0;view&#x7684;&#x58F0;&#x660E;</p>
<pre><code>    &lt;com.taobao.library.VerticalBannerView
             android:id=&quot;@+id/banner_01&quot;
             android:layout_width=&quot;match_parent&quot;
             android:layout_height=&quot;40dp&quot;
             app:animDuration=&quot;900&quot; ----&gt;&#x52A8;&#x753B;&#x95F4;&#x9694;900ms
             app:gap=&quot;2000&quot;/&gt; -----&gt;&#x5207;&#x6362;&#x65F6;&#x957F;2000ms
</code></pre></li>
<li><p>&#x8BBE;&#x7F6E;Adapter&#x5E76;&#x542F;&#x52A8;</p>
<pre><code> List&lt;Model01&gt; datas02 = new ArrayList&lt;&gt;();
 datas02.add(new Model01(&quot;Life was so beautiful&quot;,&quot;---&gt;Life was so beautiful,&quot;));
 datas02.add(new Model01(&quot;From morning to evening&quot;,&quot;---&gt;From morning to evening&quot;));
 datas02.add(new Model01(&quot;We enjoyed the road to school&quot;,&quot;---&gt;We enjoyed the road to school,&quot;));
 datas02.add(new Model01(&quot;Birds chirped and Peace lingered&quot;,&quot;---&gt;Birds chirped and Peace lingered&quot;));
 final SampleAdapter02 adapter02 = new SampleAdapter02(datas02);
 final VerticalBannerView banner02 = (VerticalBannerView) findViewById(R.id.banner_02);
 banner02.setAdapter(adapter02);
 banner02.start();
</code></pre></li>
<li><p>&#x66F4;&#x65B0;&#x6570;&#x636E;</p>
<pre><code> List&lt;Model01&gt; newData = new ArrayList&lt;&gt;();
 newData.add(new Model01(&quot;&#x9504;&#x79BE;&#x65E5;&#x5F53;&#x5348;&quot;,&quot;---&gt;&#x9504;&#x79BE;&#x65E5;&#x5F53;&#x5348;&quot;));
 newData.add(new Model01(&quot;&#x6C57;&#x6EF4;&#x79BE;&#x4E0B;&#x571F;&quot;,&quot;---&gt;&#x6C57;&#x6EF4;&#x79BE;&#x4E0B;&#x571F;&quot;));
 newData.add(new Model01(&quot;&#x8C01;&#x77E5;&#x76D8;&#x4E2D;&#x9910;&quot;,&quot;---&gt;&#x8C01;&#x77E5;&#x76D8;&#x4E2D;&#x9910;&quot;));
 newData.add(new Model01(&quot;&#x7C92;&#x7C92;&#x7686;&#x8F9B;&#x82E6;&quot;,&quot;---&gt;&#x7C92;&#x7C92;&#x7686;&#x8F9B;&#x82E6;&quot;));
 adapter02.setData(newData);
</code></pre></li>
<li><p>&#x505C;&#x6B62;</p>
<p> <code>`
 banner02.stop();</code></p>
</li>
</ol>
<h2 id="8-&#x88C5;&#x9970;&#xFF1A;drawable&#x53CA;icontextview">8 &#x88C5;&#x9970;&#xFF1A;Drawable&#x53CA;IconTextView</h2>
<h1 id="spannable&#x8BE6;&#x7EC6;&#x7814;&#x7A76;">Spannable&#x8BE6;&#x7EC6;&#x7814;&#x7A76;</h1>
<p>github&#x5730;&#x5740;&#xFF1A;<a href="https://github.com/cowthan/RichText" target="_blank">https://github.com/cowthan/RichText</a></p>
<h1 id="richtext">RichText</h1>
<p>=======
&#x591A;&#x6837;&#x5316;&#x7684;&#x6587;&#x672C;&#x5904;&#x7406;&#xFF0C;&#x6E90;&#x81EA;<a href="https://github.com/zzhoujay/Markdown&#xFF0C;&#x4F46;&#x505A;&#x4E86;&#x5927;&#x6539;&#xFF0C;&#x6240;&#x4EE5;&#x5C31;&#x4E0D;&#x5408;&#x4E86;" target="_blank">https://github.com/zzhoujay/Markdown&#xFF0C;&#x4F46;&#x505A;&#x4E86;&#x5927;&#x6539;&#xFF0C;&#x6240;&#x4EE5;&#x5C31;&#x4E0D;&#x5408;&#x4E86;</a></p>
<ul>
<li>&#x6DFB;&#x52A0;&#x4E86;Spannable&#x7684;demo</li>
<li>&#x6DFB;&#x52A0;&#x4E86;AwesomeText&#xFF0C;&#x4E00;&#x4E2A;&#x5C06;&#x4EFB;&#x610F;View&#x53D8;&#x6210;ImageSpan&#x7684;&#x5E93;&#xFF0C;&#x53EF;&#x4EE5;&#x5B9E;&#x73B0;EditText&#x5220;&#x9664;&#x4E00;&#x4E2A;&#x8BCD;&#x7EC4;</li>
</ul>
<p>&#x5173;&#x4E8E;Span</p>
<ul>
<li>TextView.setText(Spannable)</li>
<li>Spannable&#x7684;&#x5B9E;&#x73B0;&#x7C7B;&#x6709;&#xFF1A;<ul>
<li>StringSpannable: <code>SpannableString spannableString = new SpannableString(CONTENT);</code></li>
</ul>
</li>
<li>Spannable&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x6837;&#x5F0F;&#xFF0C;&#x5177;&#x4F53;&#x65B9;&#x6CD5;&#x662F;&#xFF1A;<ul>
<li><code>spannableString.setSpan(span, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);</code></li>
<li>start&#x548C;end&#x4F1A;&#x622A;&#x53D6;&#x4E00;&#x6BB5;&#x6587;&#x672C;</li>
<li>&#x53C2;&#x6570;1&#xFF1A;span&#x662F;&#x4E00;&#x4E2A;Object&#x7C7B;&#x578B;&#xFF0C;&#x8868;&#x793A;&#x4F5C;&#x7528;&#x4E8E;&#x8FD9;&#x6BB5;&#x6587;&#x672C;&#x7684;&#x6837;&#x5F0F;</li>
</ul>
</li>
<li>&#x800C;&#x5177;&#x4F53;&#x6837;&#x5F0F;&#x53C8;&#x5206;&#x4E3A;&#x56DB;&#x4E2A;&#x5206;&#x652F;&#xFF1A;<ul>
<li>&#x5982;&#x679C;&#x4E00;&#x4E2A;Span&#x5F71;&#x54CD;&#x5B57;&#x7B26;&#x5C42;&#x6B21;&#x4E0A;&#x7684;&#x6587;&#x5B57;&#x683C;&#x5F0F;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x7EE7;&#x627F;CharacterStyle&#x7C7B;<ul>
<li>MetricAffectingSpan</li>
<li>SuggestionSpan</li>
<li>BackgroundColorSpan  &#x80CC;&#x666F;</li>
<li>ClickableSpan    &#x70B9;&#x51FB;</li>
<li>ForegroundColorSpan  &#x524D;&#x666F;</li>
<li>MaskFilterSpan    &#x6A21;&#x7CCA;&#x548C;&#x6D6E;&#x96D5;</li>
<li>RasterizerSpan</li>
<li>StrikethroughSpan  &#x5220;&#x9664;&#x7EBF;</li>
<li>UnbderlineSpan  &#x4E0B;&#x5212;&#x7EBF;</li>
</ul>
</li>
<li>&#x5982;&#x679C;&#x4E00;&#x4E2A;Span&#x5F71;&#x54CD;&#x6BB5;&#x843D;&#x5C42;&#x6B21;&#x4E0A;&#x7684;&#x6587;&#x5B57;&#x683C;&#x5F0F;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x5B9E;&#x73B0;ParagraphStyle&#x63A5;&#x53E3;<ul>
<li>AlignmentSpan</li>
<li>LeadingMarginSpan</li>
<li>LineBackgroundSpan</li>
<li>LineHeightSpan</li>
<li>TabStopSpan</li>
<li>WrapTogetherSpan</li>
</ul>
</li>
<li>&#x5982;&#x679C;&#x4E00;&#x4E2A;Span&#x4FEE;&#x6539;&#x5B57;&#x7B26;&#x5C42;&#x6B21;&#x4E0A;&#x7684;&#x6587;&#x5B57;&#x5916;&#x89C2;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x5B9E;&#x73B0;UpdateAppearance&#x63A5;&#x53E3;<ul>
<li>UpdateLayout</li>
<li>BackgroundColorSpan</li>
<li>ClickableSpan</li>
<li>ForegroundColorSpan</li>
<li>MaskFilterSpan</li>
<li>RasterizerSpan</li>
<li>StrikethroughSpan</li>
<li>UnderlineSpan</li>
</ul>
</li>
<li>&#x5982;&#x679C;&#x4E00;&#x4E2A;Span&#x4FEE;&#x6539;&#x5B57;&#x7B26;&#x5C42;&#x6B21;&#x4E0A;&#x7684;&#x5EA6;&#x91CF;&#x6216;&#x8005;&#x5C3A;&#x5BF8;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x5B9E;&#x73B0;UpdateLayout&#x63A5;&#x53E3;</li>
</ul>
</li>
</ul>
<p>Spannable&#x7684;&#x6587;&#x7AE0;&#xFF1A;</p>
<ul>
<li><a href="http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0305/2535.html" target="_blank">http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0305/2535.html</a></li>
</ul>
<blockquote>
<p>Android&#x5E73;&#x53F0;&#x4E0B;&#x7684;&#x5BCC;&#x6587;&#x672C;&#x89E3;&#x6790;&#x5668;</p>
</blockquote>
<ul>
<li>&#x6D41;&#x5F0F;&#x64CD;&#x4F5C;</li>
<li>&#x4F4E;&#x4FB5;&#x5165;&#x6027;</li>
<li>&#x652F;&#x6301;Html&#x548C;Markdown&#x683C;&#x5F0F;&#x6587;&#x672C;</li>
<li>&#x652F;&#x6301;&#x56FE;&#x7247;&#x70B9;&#x51FB;&#x548C;&#x957F;&#x6309;&#x4E8B;&#x4EF6;</li>
<li>&#x94FE;&#x63A5;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;&#x548C;&#x957F;&#x6309;&#x4E8B;&#x4EF6;</li>
<li>&#x652F;&#x6301;&#x8BBE;&#x7F6E;&#x52A0;&#x8F7D;&#x4E2D;&#x548C;&#x52A0;&#x8F7D;&#x9519;&#x8BEF;&#x65F6;&#x7684;&#x56FE;&#x7247;</li>
<li>&#x652F;&#x6301;&#x81EA;&#x5B9A;&#x4E49;&#x8D85;&#x94FE;&#x63A5;&#x7684;&#x70B9;&#x51FB;&#x56DE;&#x8C03;</li>
<li>&#x652F;&#x6301;&#x4FEE;&#x6B63;&#x56FE;&#x7247;&#x5BBD;&#x9AD8;</li>
<li>&#x652F;&#x6301;GIF&#x56FE;&#x7247;</li>
<li>&#x652F;&#x6301;Base64&#x7F16;&#x7801;</li>
<li>&#x81EA;&#x6301;&#x81EA;&#x5B9A;&#x4E49;&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5668;</li>
</ul>
<h3 id="&#x6548;&#x679C;">&#x6548;&#x679C;</h3>
<p><img src="image/image.jpg" alt="&#x6F14;&#x793A;" title="&#x6F14;&#x793A;"></p>
<h3 id="gradle&#x4E2D;&#x5F15;&#x7528;&#x7684;&#x65B9;&#x6CD5;">gradle&#x4E2D;&#x5F15;&#x7528;&#x7684;&#x65B9;&#x6CD5;</h3>
<pre><code>compile &apos;com.zzhoujay.richtext:richtext:2.3.7&apos;
</code></pre><h3 id="glide&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5668;">Glide&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5668;</h3>
<pre><code>compile &apos;com.zzhoujay.glideimagegetter:glideimagegetter:1.0.1&apos;
</code></pre><p>&#x5173;&#x4E8E;Glide&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5668;&#x548C;&#x9ED8;&#x8BA4;&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5668;&#x7684;&#x533A;&#x522B;&#x8BF7;&#x770B;<a href="https://github.com/zzhoujay/RichText/wiki/&#x81EA;&#x5B9A;&#x4E49;&#x56FE;&#x7247;&#x52A0;&#x8F7D;&#x5668;" target="_blank">&#x8FD9;&#x91CC;</a></p>
<h3 id="&#x4F7F;&#x7528;&#x65B9;&#x5F0F;">&#x4F7F;&#x7528;&#x65B9;&#x5F0F;</h3>
<p><a href="https://github.com/zzhoujay/RichText/wiki" target="_blank">&#x591A;&#x770B;wiki</a>&#x3001;<a href="https://github.com/zzhoujay/RichText/wiki" target="_blank">&#x591A;&#x770B;wiki</a>&#x3001;<a href="https://github.com/zzhoujay/RichText/wiki" target="_blank">&#x591A;&#x770B;wiki</a>&#xFF0C;&#x91CD;&#x8981;&#x7684;&#x4E8B;&#x60C5;&#x8BF4;&#x4E09;&#x904D;</p>
<h3 id="&#x540E;&#x7EED;&#x8BA1;&#x5212;">&#x540E;&#x7EED;&#x8BA1;&#x5212;</h3>
<ul>
<li><del>&#x6DFB;&#x52A0;&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#x7684;&#x652F;&#x6301;</del> (&#x5DF2;&#x6DFB;&#x52A0;&#x5BF9;&#x5C11;&#x90E8;&#x5206;&#x81EA;&#x5B9A;&#x4E49;&#x6807;&#x7B7E;&#x7684;&#x652F;&#x6301;)</li>
</ul>
<h3 id="&#x5173;&#x4E8E;markdown">&#x5173;&#x4E8E;Markdown</h3>
<p>Markdown&#x6E90;&#x4E8E;&#x5B50;&#x9879;&#x76EE;&#xFF1A;<a href="https://github.com/zzhoujay/Markdown" target="_blank">Markdown</a></p>
<p>&#x82E5;&#x5728;markdown&#x89E3;&#x6790;&#x8FC7;&#x7A0B;&#x4E2D;&#x53D1;&#x73B0;&#x4EC0;&#x4E48;&#x95EE;&#x9898;&#x53EF;&#x4EE5;&#x5728;&#x8BE5;&#x9879;&#x76EE;&#x4E2D;&#x53CD;&#x9988;</p>
<h3 id="&#x5BCC;&#x6587;&#x672C;&#x7F16;&#x8F91;&#x5668;">&#x5BCC;&#x6587;&#x672C;&#x7F16;&#x8F91;&#x5668;</h3>
<p>&#x7F16;&#x8F91;&#x529F;&#x80FD;&#x76EE;&#x524D;&#x6B63;&#x5728;&#x5F00;&#x53D1;&#x4E2D;&#xFF0C;<a href="https://github.com/zzhoujay/RichEditor" target="_blank">RichEditor</a></p>
<h3 id="&#x5177;&#x4F53;&#x4F7F;&#x7528;&#x8BF7;&#x67E5;&#x770B;demo">&#x5177;&#x4F53;&#x4F7F;&#x7528;&#x8BF7;&#x67E5;&#x770B;demo</h3>
<p><a href="https://github.com/zzhoujay/RichText/blob/master/app/src/main/java/zhou/demo/ListViewActivity.java" target="_blank">ListView Demo</a>&#x3001;
<a href="https://github.com/zzhoujay/RichText/blob/master/app/src/main/java/zhou/demo/RecyclerViewActivity.java" target="_blank">RecyclerView Demo</a>&#x3001;
<a href="https://github.com/zzhoujay/RichText/blob/master/app/src/main/java/zhou/demo/GifActivity.java" target="_blank">Gif Demo</a></p>
<h3 id="&#x7279;&#x522B;&#x611F;&#x8C22;">&#x7279;&#x522B;&#x611F;&#x8C22;</h3>
<p>&#x611F;&#x8C22;<a href="https://github.com/huoguangjin" target="_blank">@huoguangjin</a>&#x5728;&#x5F00;&#x53D1;&#x8FC7;&#x7A0B;&#x4E2D;&#x5BF9;gilde&#x7684;&#x6E90;&#x7801;&#x5206;&#x6790;&#x7684;&#x5E2E;&#x52A9;</p>
<h3 id="license">License</h3>
<pre><code>The MIT License (MIT)

Copyright (c) 2016 zzhoujay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the &quot;Software&quot;), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
</code></pre><p><em>by zzhoujay</em></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="layout.html" class="navigation navigation-prev " aria-label="Previous page: Layout">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="drawable.html" class="navigation navigation-next " aria-label="Next page: Drawable">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"TextView","level":"1.10","depth":1,"next":{"title":"Drawable","level":"1.11","depth":1,"path":"drawable.md","ref":"drawable.md","articles":[]},"previous":{"title":"Layout","level":"1.9","depth":1,"path":"layout.md","ref":"layout.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"textview.md","mtime":"2017-04-09T15:02:29.509Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-04-09T17:03:25.521Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

